package com.tyc.mb.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.stereotype.Component;

/**
 * 类描述
 *
 * @author tyc
 * @version 1.0
 * @date 2021-10-25 18:01:24
 */
@Component
public class DynamicDataSource extends AbstractRoutingDataSource {
    @Autowired
    private DataSourceContextHolder dataSourceHolder;

    @Override
    protected Object determineCurrentLookupKey() {
        return dataSourceHolder.getDataSourceKey();
    }
}
